package com.hejl.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Hejl
 * @version 1.0
 * @description
 * @className TestAIController
 * @date 2025/6/9 10:39
 */
@RestController
public class TestAIController {
    private final ChatClient chatClient;

    public TestAIController(ChatClient.Builder builder) {
        this.chatClient = builder.build();
    }

    @GetMapping("/chat")
    public String chat(@RequestParam(value = "input") String input) {
        String result=chatClient.prompt().user(input).call().content();
        System.out.println(result);
        return result;
    }

}